<#-- 导入模版定义文件-->
<#include "../template/template_editPage.ftl">
<@edit title="banner管理">

<body class="input">
<script type="text/javascript">
	$().ready( function() {	
		var $validateErrorContainer = $("#validateErrorContainer");
		var $validateErrorLabelContainer = $("#validateErrorContainer ul");
		var $validateForm = $("#inputForm");
		var $tab = $("#tab");
	
		// Tab效果
		$tab.tabs(".tabContent", {
			tabs: "input"
		});
		
		// 表单验证
		$validateForm.validate({
			errorContainer: $validateErrorContainer,
			errorLabelContainer: $validateErrorLabelContainer,
			wrapper: "li",
			errorClass: "validateError",
			ignoreTitle: true,
			rules: {
				"bannerInfo.bannerUrl": {
						url: true
				},
				"bannerInfo.bannerBelong": {
						required: true
				},
				"bannerInfo.bannerOrder": {
						required: true
				}
			},
			messages: {
				"bannerInfo.bannerUrl": {
						url: "请输入正确格式的链接"
				},
				"bannerInfo.bannerBelong": {
						required: "请选择banner所属模块"
				},
				"bannerInfo.bannerOrder": {
						required: "请选择banner展示位置"
				}
			},
			submitHandler: function(form) {
				$(form).find(":submit").attr("disabled", true);
				form.submit();
			}
		});
		<#if actionErrors??&&(actionErrors?size > 0)>
			$.dialog({type: "warn", content: "<#list errorMessages as list>${list}<br></#list>",
			 modal: true, autoCloseTime: 3000});
		</#if>
		<#if actionMessages??&&(actionMessages?size > 0)>
			$.dialog({type: "success", content: "<#list actionMessages as list>${list}<br></#list>",
			 modal: true, autoCloseTime: 5000});
		</#if>
    
	});
	
	function showDiv(){
    new uploadPreview({ UpBtn: "bannerPic", DivShow: "imgdiv", ImgShow: "imgShow" });
	}
	
	function clearImg(){
		var obj = document.getElementById('bannerPic') ;   
		obj.outerHTML=obj.outerHTML;  
		
		$('#imgShow').attr("src", "");
	}
	
	function imgError(){
		$('#bannerPic').addClass('{required: false}');
	}
	

</script>
	<div class="body">
		<div class="inputBar">
			<h1><span class="icon">&nbsp;</span><#if id??>编辑Banner内容<#else>新增Banner内容</#if></h1>
		</div>
		<div style="display: none;" id="validateErrorContainer" class="validateErrorContainer">
			<div class="validateErrorTitle">以下信息填写有误,请重新填写</div>
				<ul></ul>
			</div>
		</div>		
		<form id="inputForm" class="validate" action="<#if id??>${web_base}/go/banner!edit.htm<#else>${web_base}/go/banner!save.htm</#if>" method="post" enctype="multipart/form-data">
			<input type="hidden" name="bannerInfo.id" value="${(bannerInfo.id)!}"/>
			<input type="hidden" name="bannerInfo.oldBannerOrder" value="${(bannerInfo.oldBannerOrder)!}"/>
			<table class="inputTable tabContent">
				<tr>
					<th>
						添加Banner图片：
					</th>
					<td>
					<div style="float:left">
    				<input type="file" id="bannerPic" name="bannerPic" value="添加图片" onclick="showDiv()"/>
						<div id="imgdiv"><img id="imgShow" width="160" height="100" onerror="imgError()" src="${(web_base + (bannerInfo.bannerPath))!}"/>
							<span class="spanLink" onclick="clearImg()" title="删除">[删除]</span><label class="requireField">*</label>
						</div>
						
					</div>
					</td>
				</tr>
				<tr>
					<th>
						添加链接：
					</th>
					<td>
						<input type="text" id="url" name="bannerInfo.bannerUrl" class="formText defaultInvalid url"
						<#if bannerInfo?? && bannerInfo.bannerUrl??>value="${(bannerInfo.bannerUrl)!}"<#else>value=""</#if> />
					</td>
				</tr>
				<tr>
					<th>
						Banner所属模块：
					</th>
					<td>
						<select name="bannerInfo.bannerBelong">
						    <option value="" >全部</option>
							<option value="1" <#if bannerInfo?? && bannerInfo.bannerBelong?? && bannerInfo.bannerBelong=="1">selected="selected"</#if> >首页</option>
							<option value="2" <#if bannerInfo?? && bannerInfo.bannerBelong?? && bannerInfo.bannerBelong=="2">selected="selected"</#if> >家族公益</option>
						</select>
					</td>
				</tr>
				<tr>
					<th>
						Banner所属位置：
					</th>
					<td>
						<select name="bannerInfo.bannerOrder">
						    <option value="" >全部</option>
							<option value="1" <#if bannerInfo?? && bannerInfo.bannerOrder?? && bannerInfo.bannerOrder=="1">selected="selected"</#if> >位置1&nbsp;</option>
							<option value="2" <#if bannerInfo?? && bannerInfo.bannerOrder?? && bannerInfo.bannerOrder=="2">selected="selected"</#if> >位置2&nbsp;</option>
							<option value="3" <#if bannerInfo?? && bannerInfo.bannerOrder?? && bannerInfo.bannerOrder=="3">selected="selected"</#if> >位置3&nbsp;</option>
							<option value="4" <#if bannerInfo?? && bannerInfo.bannerOrder?? && bannerInfo.bannerOrder=="4">selected="selected"</#if> >位置4&nbsp;</option>
							<option value="5" <#if bannerInfo?? && bannerInfo.bannerOrder?? && bannerInfo.bannerOrder=="5">selected="selected"</#if> >位置5&nbsp;</option>
							<option value="6" <#if bannerInfo?? && bannerInfo.bannerOrder?? && bannerInfo.bannerOrder=="6">selected="selected"</#if> >位置6&nbsp;</option>
							<option value="7" <#if bannerInfo?? && bannerInfo.bannerOrder?? && bannerInfo.bannerOrder=="7">selected="selected"</#if> >位置7&nbsp;</option>
							<option value="8" <#if bannerInfo?? && bannerInfo.bannerOrder?? && bannerInfo.bannerOrder=="8">selected="selected"</#if> >位置8&nbsp;</option>
						</select>
					</td>
				</tr>
			</table>
			<div class="buttonArea">
				<input type="submit" class="formButton" value="提 交" hidefocus="true" />&nbsp;&nbsp;&nbsp;&nbsp;
				<input type="button" class="formButton" onclick="window.history.back(); return false;" value="返  回" hidefocus="true" />
			</div>
		</form>
	</div>
</body>
</@edit>